﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace AllInOne
{
    /// <summary>
    /// InPutNumberWin.xaml 的交互逻辑
    /// 手动输入数字信息
    /// </summary>
    public partial class InPutNumberWin : Window
    {
        public string oldNumber;

        public string newNumber;
        public InPutNumberWin(string inputTitle, string number)
        {
            InitializeComponent();
            txtTip.Text = "请输入" + inputTitle;
            txtVin.Text = number.ToString();
            oldNumber = number;
        }

        private void BtnSubmit_MouseUp(object sender, MouseButtonEventArgs e)
        {
            try
            {
                newNumber = txtVin.Text.Trim();
                this.DialogResult = true;
            }
            catch (Exception)
            {
                MessageBox.Show("输入数据有误");
            }
        }

        private void BtnCancel_MouseUp(object sender, MouseButtonEventArgs e)
        {
            newNumber = oldNumber;
            this.DialogResult = false;
        }

        private void BtnService_MouseUp(object sender, MouseButtonEventArgs e)
        {
            string sjhm = txtVin.Text;
            TextBlock btn = (TextBlock)sender;
            string key = btn.Text;
            txtVin.Text = sjhm + key;
        }

        private void BtnClear_MouseUp(object sender, MouseButtonEventArgs e)
        {
            txtVin.Text = "";
        }

        private void BtnBackspace_MouseUp(object sender, MouseButtonEventArgs e)
        {
            string sjhm = txtVin.Text;
            if (sjhm != null && sjhm.Length > 0)
            {
                txtVin.Text = sjhm.Substring(0, sjhm.Length - 1);
            }
        }

        private void WinMove_LeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
            }
        }
    }
}
